package com.hundsun.yr.universal.p2p.interactor.impl;

import android.content.Context;
import android.content.res.TypedArray;
import android.text.TextUtils;

import com.hundsun.mobile.zwgt.R;
import com.hundsun.yr.universal.library.data.HSSharedPreferences;
import com.hundsun.yr.universal.p2p.bean.UserInfo;
import com.hundsun.yr.universal.p2p.config.Config;
import com.hundsun.yr.universal.p2p.interactor.base.BaseItemViewInteractor;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * @version V1.0
 * @Title: MineInteractorImpl.java
 * @Description: TODO(用一句话描述该文件做什么)
 * @date 2015-10-27 上午11:16:52
 * @author:hejun.shen
 * @email:shenhj15971@hundsun.com
 * @replace author:
 * @replace date:
 */
public class MineInteractorImpl implements BaseItemViewInteractor {
    public HSSharedPreferences sharedPreferences = null;
    public String vip = "0";

    @SuppressWarnings("unchecked")
    @Override
    public List<HashMap<String, Object>> getListItemData(Context context) {
        // TODO Auto-generated method stub
        List<HashMap<String, Object>> mListData = new ArrayList<HashMap<String, Object>>();
        sharedPreferences = new HSSharedPreferences(context, Config.SPPath.file_userLoginedInfo);
        vip = sharedPreferences.getShareProf(UserInfo.VIPLEVEL);

        TypedArray a;
        String[] item_names;
        if (TextUtils.equals(vip,"0") || vip.isEmpty()){
            a = context.getResources().obtainTypedArray(R.array.mine_item_icon_no_bid);
            item_names = context.getResources().getStringArray(R.array.mine_item_name_no_bid);
        } else {
            a = context.getResources().obtainTypedArray(R.array.mine_item_icon);
            item_names = context.getResources().getStringArray(R.array.mine_item_name);
        }

        for (int i = 0; i < a.length(); i++) {
            HashMap<String, Object> map = new HashMap<String, Object>();
            map.put("item_name", item_names[i]);
            map.put("item_icon", a.getResourceId(i, 0));
            mListData.add(map);
        }
        a.recycle();
        return mListData;
    }

}
